<?php html_js('jquery.pagination.js');?>
<div class="reply">
	<div class="reply-top">
		<div class="reply-top-title fb c2">
			<?php echo $count_reply;?> 条评论
		</div>
		<div class="reply-top-frm">
			<form id="frm-reply" action="<?php echo site_url('c=topic&m=reply_do');?>"
				submitbefor="reply_befor"
				submitafter="reply_after"
			>
				<input type="hidden" value="<?php echo $r->id;?>" name="tid"/>
				<input id="smy" class="inp1" name="smy"/>
				<a class="btn btn-7 btn-ajax-submit" frmid="frm-reply" href="javascript:void(0);">发表</a>
			</form>
		</div>
	</div>
	
	<div class="b1"></div>
	
	<div class="reply-cont">
		<div id="reply-item-container">
		</div>
		<div class="b1"></div>
		<div id="reply-page" class="ajax-page"></div>
	</div>
</div>	

<script>

$(function(){
	$("#reply-page").pagination(<?php echo $count_reply;?>,{
	    num_edge_entries: 2,
	    num_display_entries: 4,
	    link_to:'#reply-item-container',
	    callback: reply_page,
	    items_per_page:<?php echo REPLY_PAGESIZE;?>
	});
});

function reply_page(i){
	var url = '<?php echo site_url('c=reply&m=ajaxlist&id='.$r->id);?>' + '&pagenum='+(i+1);
	$('#reply-item-container').html('').load(url);
}

function reply_befor($frm){
	var smy = $('#smy').val().trim();
	if(smy.length == 0){
		asyncbox.tips('内容不能为空！','error');
		return false;
	}
	return true;
}

function reply_after(msg,$frm){
	$('#smy').val('');
	reply_page(0);
	$("#reply-page").pagination(msg.data.total,{
	    num_edge_entries: 2,
	    num_display_entries: 4,
	    link_to:'#reply-item-container',
	    callback: reply_page,
	    items_per_page:<?php echo REPLY_PAGESIZE;?>
	});
	return true;
}
</script>